//
// Created by jingjia on 2021/10/15.
//

#ifndef JINGJIA_JVM_CPP_MUTEXLOCKER_H
#define JINGJIA_JVM_CPP_MUTEXLOCKER_H

#include "../precompiled/precompiled.hpp"
#include "../runtime/mutex.hpp"

class MutexLockerEx : StackObj {
private:
    Monitor* _monitor;
public:
    MutexLockerEx(Monitor* monitor) {
        _monitor = monitor;
        if(_monitor != NULL)
            _monitor->lock();
    }
    ~MutexLockerEx() {
        if(_monitor != NULL)
            _monitor->unlock();
    }
};


#endif //JINGJIA_JVM_CPP_MUTEXLOCKER_H
